package com.axxc.cloud.rest;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import com.axxc.cloud.service.CrossDataBaseTranscationService;

@RestController
public class UserController {

	@Autowired
	private com.axxc.cloud.mapper.master.MasterUserMapper masterUserMapper;
	@Autowired
	private com.axxc.cloud.mapper.slave.SlaveUserMapper slaveUserMapper;

	@Autowired
	CrossDataBaseTranscationService crossDataBaseTranscationService;

	@GetMapping("/{type}")
	public List<String> list(@PathVariable("type") String type) {
		if (type.equals("1")) {
			return masterUserMapper.listAllUserMaster();
		} else {
			return slaveUserMapper.listAllUserSlave();
		}
	}

	@GetMapping("/insert")
	public void insert() {
		crossDataBaseTranscationService.insert();
	}

}
